<?php
$this->placeholder("navegacion")->set($this->navegacion($this->nav));

$domConfig = Zend_Registry::get('domConfig');
$perfil = App_Perfil::getInstance();
$perfil->cargar("MISVARIABLES");

if(count($this->datos)>0):?>
<table id="table_id" align="center" class="display">
  <thead>
    <tr>
      <th width="10%">C&oacute;digo</th>
      <th width="25%">Nombre variable / dimensi&oacute;n</th>
      <th width="15%">Periodicidad</th>
      <th width="15%">Unidad</th>
      <th width="15%">Valor actual</th>
      <th width="10%">&Uacute;ltima actualizac&oacute;n</th>
      <th width="10%">Acciones</th>
    </tr>
  </thead>
  <tbody>
	<?php
	foreach ($this->datos as $key => $value):
	?>
    <tr>
      <td><?php echo $value["coddimension"];?></td>
      <td><?php echo $value["nombredimension"];?></td>
	  <td><?php echo $domConfig->PERIODICIDAD->$value["periodicidad"];?></td>
	  <td><?php echo $value["nombreunidad"];?></td>
	  <td><?php
	      if ($value["tiponaturaleza"]==1){
	          echo $value["valornum"];
	      }else{
	          echo $value["valortexto"];
	      }
	  ?></td>
	  <td><?php
	           echo $value["fechaactualiza"];
               if (empty($value["fechaactualiza"]) || strtotime($value["fechavigencia"]) < strtotime($value["fechaactualiza"])):
                  echo "<span style=\"color:red;\"><br>Desactualizada</span>";
               endif;
	          ?>
	  </td>
      <td>
        <?php
        $params=App_Util_SafeUrl::encriptar(array("coddimension"=>$value["coddimension"],"codvariable"=>$value["codvariable"]),true);
        $tools = new App_Util_ToolButton();
        $tools->add($this->baseUrl("/variables/index/actualizardimension/{$params}"), "Actualizar variable", "glyphicon glyphicon-refresh", true);
        $tools->add($this->baseUrl("/variables/index/historicodimension/{$params}"), "Datos históricos", "glyphicon glyphicon-list-alt", true);
        echo $tools->render();
   		?>
      </td>
    </tr>
  <?php  endforeach;?>
  </tbody>
</table>

<script type="text/javascript">
 $(function() {
	$('#table_id').dataTable({
		"bJQueryUI": true,
		"bAutoWidth": false,
 		"sPaginationType": "full_numbers",
 		"bStateSave": true,
 		"aoColumns": [
 	 		 			{ "sType": "numeric" },
 	 		 			null,
 	 		 			null,
 	 		 			null,
 	 		 			null,
 	 		 			null,
 	 		 			{ "bSortable": false, "bSearchable": false }
 	 		 		 ]
 	 		  		
	});

});
</script>
<?php else:?>
<br/>
<?php echo $this->mensajes("No existen registros");?>
<?php endif;?>
